home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 18
/
CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso
/
CUCD
/
Magazine
/
C_Tutorial
/
Part-6
/
asl2
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-27
|
2KB
|
116 lines
#include<exec/libraries.h>
#include<stdio.h>
#include<clib/exec_protos.h>
#include "bitmap.h"
#include "drawwin.h"
#include "gadgets.h"
#include "idcmp.h"
#include "loadsave.h"
#include "menu.h"
#include "screen.h"
#include "toolwin.h"
#include "visual.h"
/* The library base global variables */
/* (The different style of opening libraries requires these to be initialised to NULL) */
struct Library* GfxBase = NULL;
struct Library* IntuitionBase = NULL;
struct Library* GadToolsBase = NULL;
struct Library* AslBase = NULL;
struct Library* DosBase = NULL;
struct Library* IFFBase = NULL;
/* Need to give prototypes for our functions */
int createAll(void);
void freeAll(void);
int openLibs(void);
void closeLibs(void);
/* The initial screen depth */
#define SCR_DEPTH (4)
/* The start of the program */
void main()
{
if(createAll())
handleIDCMP();
freeAll();
}
int createAll()
{
return openLibs() && openScreen(SCR_DEPTH,0,0,0) &&
createBitmap() && createVisual() &&
createMenuStrip() && createGadgets() &&
openToolWin() && openDrawWin();
}
void freeAll()
{
freeReqs();
closeDrawWin();
closeToolWin();
freeGadgets();
freeMenuStrip();
freeVisual();
freeBitmap();
closeScreen();
closeLibs();
}
/* Try to open all the libraries -- return TRUE on success */
int openLibs()
{
if((GfxBase = OpenLibrary("graphics.library",37)) == NULL)
{
printf("Error: could not open graphics.library\n");
return FALSE;
}
if((IntuitionBase = OpenLibrary("intuition.library",37)) == NULL)
{
printf("Error: could not open intuition.library\n");
return FALSE;
}
if((GadToolsBase = OpenLibrary("gadtools.library",37)) == NULL)
{
printf("Error: could not open gadtools.library\n");
return FALSE;
}
if((AslBase = OpenLibrary("asl.library",37)) == NULL)
{
printf("Error: could not open asl.library\n");
return FALSE;
}
if((DosBase = OpenLibrary("dos.library",37)) == NULL)
{
printf("Error: could not open dos.library\n");
return FALSE;
}
if((IFFBase = OpenLibrary("iff.library",23)) == NULL)
{
printf("Error: could not open iff.library\n");
return FALSE;
}
return TRUE;
}
/* Close any open library */
void closeLibs()
{
if(IFFBase)
CloseLibrary(IFFBase);
if(DosBase)
CloseLibrary(DosBase);
if(AslBase)
CloseLibrary(AslBase);
if(GadToolsBase)
CloseLibrary(GadToolsBase);
if(IntuitionBase)
CloseLibrary(IntuitionBase);
if(GfxBase)
CloseLibrary(GfxBase);
}